<?php
namespace App\Api\V1\Models;

use Illuminate\Database\Eloquent\Model;

class Transaction extends Model{
    /**
     * 收入
     * @var int
     */
    protected $table = 'transaction';
    public $timestamps = false;
    const TRANSACTION_INCOME = 0;

    /**
     * 支出
     * @var int
     */
    const TRANSACTION_EXPENDITURE = 1;

    /**
     * 主键
     * @var string
     */
    protected $pk = 'transaction_id';

    /**
     * 是否需要自动写入时间戳
     * @var bool
     */
    protected $autoWriteTimestamp = true;

    /**
     * 更新日期字段
     * @var bool|string
     */
    protected $updateTime = false;

    /**
     * 字段类型或者格式转换
     * @var array
     */
    protected $type = [
        'transaction_id' => 'integer',
        'user_id'        => 'integer',
        'type'           => 'integer',
        'amount'         => 'float',
        'balance'        => 'float',
        'to_payment'     => 'integer',
    ];
    public function getUser(){
        return 123;
    }
    public function getTransactionItem(){
        return $this->get()->toArray();
    }
    public function getTransactionList(){
        return $this->get()->toArray();
    }
}
